package com.aspire.aimini.model.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 生成记录实体类
 *
 * @author wangguiyou
 * @date 2024-01-01
 * @description 记录AI生成操作的详细信息的实体类
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("generation_records")
public class GenerationRecord implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 主键ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 用户ID
     */
    @TableField("user_id")
    private Long userId;

    /**
     * 源素材ID
     */
    @TableField("source_material_id")
    private Long sourceMaterialId;

    /**
     * 目标素材ID
     */
    @TableField("target_material_id")
    private Long targetMaterialId;

    /**
     * 文案ID
     */
    @TableField("copywriting_id")
    private Long copywritingId;

    /**
     * 生成类型(text/image/tag)
     */
    @TableField("generation_type")
    private String generationType;

    /**
     * AI服务提供商
     */
    @TableField("ai_provider")
    private String aiProvider;

    /**
     * 使用模型
     */
    @TableField("model_name")
    private String modelName;

    /**
     * 输入参数(JSON格式)
     */
    @TableField("input_params")
    private String inputParams;

    /**
     * 输出结果(JSON格式)
     */
    @TableField("output_result")
    private String outputResult;

    /**
     * 消耗token数
     */
    @TableField("cost_tokens")
    private Integer costTokens;

    /**
     * 消耗金额
     */
    @TableField("cost_amount")
    private BigDecimal costAmount;

    /**
     * 耗时(毫秒)
     */
    @TableField("duration_ms")
    private Integer durationMs;

    /**
     * 状态(pending/success/failed)
     */
    @TableField("status")
    private String status;

    /**
     * 错误信息
     */
    @TableField("error_message")
    private String errorMessage;

    /**
     * 创建时间
     */
    @TableField(value = "created_time", fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createdTime;
}